# 协程

import asyncio


from test_queue import RedisQueue,MysqlDb



# 实例化对象
mydb = MysqlDb()



async def doout(id):

	print(id)

	rq = RedisQueue("rq")

	uid = rq.get_wait(1)

	if uid:

		# 修改字段  将审批人分配给 审批人   set auid = id where id = uid

		sql = " update `user` set `auid` = %s where `id` = %s " % (id,uid[1])

		print(sql)

		mydb.update(sql) 

		# time.sleep(1)

		print(uid[1])

# 执行的方法
async def main():

	# 建立协程对象
	task1 = asyncio.ensure_future(doout(4))
	task2 = asyncio.ensure_future(doout(7))

	tasks = [task1,task2]

	# 异步执行
	await asyncio.gather(*tasks)


# 通过协程库执行任务
asyncio.run(main())



